<?php
/*
	Muffinz CMS - A website content management system.
	Copyright (C) 2010-2011 Sigitas Zelenkovas

	This program is free software; you can redistribute it and/or
	modify it under the terms of the GNU General Public License
	as published by the Free Software Foundation; either version 2
	of the License, or (at your option) any later version.

	This program is distributed in the hope that it will be useful,
	but WITHOUT ANY WARRANTY; without even the implied warranty of
	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
	GNU General Public License for more details.

	You should have received a copy of the GNU General Public License
	along with this program; if not, write to the Free Software
	Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
	
	Optionally you can also view the license at <http://www.gnu.org/licenses/>.
*/

class Plugin_UserPanel{
	private $UniqueID = "Miiv260hfiG9SP66GbFbnusJ81Aoq6o5";
	private $panelMenuItems = array();
	
	public function Add($text, $link, $ali = true){
		global $cTheme;
		$this->panelMenuItems[] = array($text, $link, $ali); 
	}
	
	public function Set(){
		global $cTheme, $user, $panel;
		
		$buffer = "";
		if($_SESSION['user'] != null){
			foreach($this->panelMenuItems as $item){
				if($item[2] == true){
					$buffer .= "<li><a href=\"{$item[1]}\"><span class=\"bullet\">&middot;&nbsp;</span><span>{$item[0]}</span></a></li>";
				}else {
					$buffer .= "<li><span>{$item[0]}</span></li>";
				}
			}
			
			$cTheme->AddPanel("Welcome <a href=\"{$_SESSION['sys']['core_link_full']}{$_SESSION['sys']['core_link']}user/{$_SESSION['user']['username']}.html\"><b>{$_SESSION['user']['username']}</b></a>", "<div style=\"text-align:center\">".$user->GetAvatar(true)."</div><br />".$buffer, $panel->GetPlace($this->UniqueID));
		}
	}
}

$Plugin_UserPanel = new Plugin_UserPanel();
$Plugin_UserPanel->Add("Edit profile", "{$_SESSION['sys']['core_link_full']}{$_SESSION['sys']['core_link']}edit-profile.html");
$Plugin_UserPanel->Add("Logout", "{$_SESSION['sys']['core_link_full']}{$_SESSION['sys']['core_link']}logout.html");
$Plugin_UserPanel->Set();